;
define(function (required, exports, modules) {
    var modal = require('mods/modal')
    var _csrf = $('#csrf').val()
    exports.set_mediation = function () {
        $('.med-save').click(function () {
            if ($(this).hasClass('disabled')) {
                modal.alert('系统正在处理中~~,请不要重复请求');
                return false
            }

            var user_name = $('input[name=user-name]').val()
            var user_phone = $('input[name=user-phone]').val()
            var user_company = $('input[name=user-company]').val()
            var user_ID = $('input[name=user-ID]').val()
            var user_id = $('input[name=user-id]').val()

            if (user_name.length < 2) {
                modal.msg('请填写正确的用户名称')
                return false
            }
            if (user_phone.length != 11) {
                modal.msg('请填写正确的用户手机号码')
                return false
            }
            if (user_ID.length != 15 && user_ID.length != 18) {
                modal.msg('请填写正确的身份证')
                return false
            }

            if (user_company.length < 2) {
                modal.msg('请填写正确的用户单位')
                return false
            }

            $(this).addClass('disabled')

            $.ajax({
                url: '/admin/mediation/set',
                type: 'POST',
                dataType: 'json',
                data: {
                    user_name: user_name,
                    user_phone: user_phone,
                    user_ID: user_ID,
                    user_id: user_id,
                    user_company: user_company,
                    _csrf: _csrf
                },
                success: function (res) {
                    if (res.code == 200) {
                        modal.msg(res.msg, {}, function () {
                            window.location.href = '/admin/mediation/index'
                        })
                    } else {
                        modal.alert(res.msg)
                        return false
                    }
                }
            })
        })
    }
})